<?php
include("VerifySession.php");

include("Header.php");
include("SNManager.class.php");

$db = new SNDataManager();
$serail_num="";
$found_serial= false;
$found_dup_comment =false;
$found_comm_date= getdate();

if($_REQUEST["txtSerialNumber"])
{
    $serail_num = $_REQUEST["txtSerialNumber"];
    $result = $db->FindSerialNumber($serail_num);	
    while($row = mysql_fetch_array($result))
    {
        $found_serial =true;
        break;
    }
    
    $result_dup =$db->CheckDupicateComment($serail_num);
    
     while($row = mysql_fetch_array($result_dup))
    {
        $found_dup_comment =true;
        $found_comm_date = $row["CREATE_DATE"];
        break;
    }
    
    unset( $_REQUEST["txtSerialNumber"]);
}


?>
<!-- Article -->
   <div id="adbox" >
                <h2><span >Find Serial Number</span>              </h2>
              <form id="form1" name="form1" method="post" action="">
    <div align="center">
    <table width="600" border="0" align="center" class="entry" >
	    <tr>
	      <td width="200" class="entry"><div align="right">Serial Number : </div></td>
	      <td width="200"  class="entry" ><input name="txtSerialNumber" type="text" id="txtLoginName"  width="300" /></td>
	      <td width="200"  class="entry" ><label for="txtRefSN"></label>
          <div align="left"><input name="btnLogIn" type="submit"  id="btnLogIn" value="Search" /> </div></td>
        </tr>
        </table>
        </div>
         </form>
            </div> 
  <?php
      if($serail_num)
      { ?>
            <!-- Article -->
           <div id="adbox">  
          <!--  <h2><span>Find Serial Number Result</span></h2>    -->         
       </div> 
           <!-- /article -->
           <div align="center">
             <?php  if($found_serial){ ?>
                 <table width="200" border="0" align="center" >
                    <tr>
                         <th width="200" align="center" scope="col"><img src="images/Found.png" width="49" height="49" /></th>
                    </tr>
                    <tr>
                         <th width="200" align="center" nowrap="nowrap">Found Serial Number</th>
                    </tr>
                    <?php
                    if($found_dup_comment)
                    { ?>
                    <tr>          
                      <th width="200" align="center" nowrap="nowrap">
                      <font color="red">To be checked on <?php echo $found_comm_date; ?>.</font>
                      </th>
                      </tr>
                     <?php } ?>
                  </table>
             <?php }else {  ?>
                 <table width="200" border="0" align="center" >
                    <tr>
                      <th width="200" align="center" scope="col"><img src="images/NotFound.png" width="49" height="49" /></th>
                    </tr>
                    <tr>
                        <th width="200" align="center">Invalid Serial Number</th>
                    </tr>
                  </table>
             <?php }?>
      <?php  
      }
      ?>
       </div> 
      <?php  
       if($found_serial && !$found_dup_comment) 
       {
        ?>
      <div id="adbox" >
         <h2><span>Comment</span></h2>
         <div align="center">
         <form id="form2" name="form2" method="post" action="SaveUserComment.php">
              <table width="600" border="0" align="center" >
              <tr>
                <td width="300" align="right" class="entry"><div align="right">Serial Number : </div></td>
                <td width="300"  class="entry" ><input name="txtRefSN" type="text" id="txtRefSN"  value="<?php echo $serail_num; ?>" readonly="readonly"  width="300" />
                  <font color="#FF0000">*</font></td>
                </tr>
              <tr>
                <td width="300" align="right" class="entry"><div align="right">ID Card/Passport No : </div></td>
                <td width="300"  class="entry" ><input name="txtIDCard" type="text" id="txtIDCard"  width="300" /><font color="#FF0000">*</font></td>
                </tr>
              <tr>
                <td width="300" align="right" class="entry"><div align="right">Name : </div> </td>
                <td width="300"  class="entry" ><input name="txtComName" type="text" id="txtComName"  width="300" /><font color="#FF0000">*</font></td>
                </tr>
              <tr>
                <td width="300" align="right" class="entry"><div align="right">Email : </div></td>
                <td width="300"  class="entry" ><input name="txtComEmail" type="text" id="txtComEmail"  width="300" /><font color="#FF0000">*</font></td>
                </tr>
              <tr>
                <td width="300" align="right" class="entry"><div align="right">Tel : </div></td>
                <td width="300"  class="entry" ><input name="txtComTel" type="text" id="txtComTel"  width="300" /><font color="#FF0000">*</font></td>
                </tr>
              <tr>
                <td width="300" align="right" class="entry"><div align="right">Comment :</div> </td>
                <td width="300"  class="entry" >
                  <label for="txtComment"></label>
                  <textarea name="txtComment" id="txtComment" cols="50" rows="6"></textarea></td>
                </tr>
              <tr>
              	<td width="300" align="right" class="entry">&nbsp;</td>
	      <td width="300"  class="entry" >
          <div align="left"><input name="btnSaveComment" type="submit" class="btnExample" id="btnSaveComment" value="Send Comment" /></div> </td>
	      </tr>
               </table>
         </form>
          </div>
            </div>
            <?php
             } ?>     
  <?php
  include("Footer.php");
  ?>
